<%--
  Created by IntelliJ IDEA.
  User: Yy
  Date: 2022/5/16
  Time: 14:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>修改学生成绩</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/layui.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/layui/layui.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/jquery-3.5.1.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/ajaxForm.js"></script>
    <script>
        layui.use(['form', 'laydate', 'layer'], function () {
            var form = layui.form, laydate = layui.laydate, layer = layui.layer;
            laydate.render({
                elem: '#scoreTime',
                type: 'date',//指定日期选择器类型 date,time,datetime
                trigger: 'click'
            });

            form.verify({
                newmobile: function(value,item){
                    var min=item.getAttribute('layui-min');
                    if(value.length > min && value>100){
                        return '长度不能超过三位数不能超过100';
                    }
                },
                chineseName: function (value) {
                    let pattern = /[\u4e00-\u9fa5]/;//中文验证
                    let txt = pattern.test(value);

                    if (value.length < 1 || !txt) {
                        return '维修设备必须是中文';
                    }
                },
                // v_pass:[/^[\s]{1,3}$/,'长度不能超过三位数'],
                numberRequiredFalse:[/(^$)|^\d+$/,'只能填写数字'],//非必填项，填了就会进行验证
                username: function (value, item) { //value：表单的值、item：表单的DOM对象
                    if (!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)) {
                        return '不能有特殊字符';
                    }
                    if(/(^\_)|(\__)|(\_+$)/.test(value)){
                        return '首尾不能出现下划线\'_\'';
                    }

                }
            });
            //监听表单提交
            form.on('submit(formbtn)', function () {
                $("#formsbt").ajaxSubmit({
                    type: "post",
                    url: '${pageContext.request.contextPath}/stu/updstuscore',
                    success: function (data) {//添加成功的回调函数
                        var index = parent.layer.getFrameIndex(window.name);//获取Frame索引
                        parent.layer.close(index);//关闭当前frame
                        parent.layui.table.reload("titleStu");//可以对父窗口进行刷新
                    }
                });
            });

            //给表单赋值
            $(function(){
                form.val('formsbt',${stuscore})
                form.render();
            });

        });
    </script>
</head>
<body>
    <form class="layui-form" id="formsbt" lay-filter="formsbt">
        <%--    成绩表id  --%>
        <div class="layui-form-item">
            <div class="layui-input-inline">
                <input type="hidden" name="scoreId" id="scoreId"  autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <%--        录入人员id--%>
        <div class="layui-form-item">
            <div class="layui-input-inline">
                <input type="hidden" name="empId" id="empId" class="layui-input" >
            </div>
        </div>
        <%--     学生    --%>
        <div class="layui-form-item">
            <label class="layui-form-label">学生:</label>
            <div class="layui-input-inline">
                <select name="stuId">
                    <c:forEach items="${stulist}" var="e">
                        <option value="${e.stuId}">${e.stuname}</option>
                    </c:forEach>
                </select>
            </div>
            <div class="layui-form-mid layui-word-aux">必填项</div>
        </div>
        <%--考试成绩--%>
        <div class="layui-form-item">
            <label class="layui-form-label">考试成绩：</label>
            <div class="layui-input-inline">
                <input type="text" name="score" id="score" placeholder="考试成绩"
                       autocomplete="off" class="layui-input" lay-verify="required|newmobile">
            </div>
            <div class="layui-form-mid layui-word-aux">必填项</div>
        </div>

        <%--考试成绩--%>
        <div class="layui-form-item">
            <label class="layui-form-label">补考成绩：</label>
            <div class="layui-input-inline">
                <input type="text" name="rescore" id="rescore" placeholder="补考成绩"
                       autocomplete="off" class="layui-input" lay-verify="required">
            </div>
            <div class="layui-form-mid layui-word-aux">必填项</div>
        </div>

        <%--     课程名    --%>
        <div class="layui-form-item">
            <label class="layui-form-label">课程名:</label>
            <div class="layui-input-inline">
                <select name="courseId">
                    <c:forEach items="${clist}" var="e">
                        <option value="${e.courseId}">${e.courseName}</option>
                    </c:forEach>
                </select>
            </div>
            <div class="layui-form-mid layui-word-aux">必填项</div>
        </div>

        <%--     考试类型    --%>
        <div class="layui-form-item">
            <label class="layui-form-label">考试类型:</label>
            <div class="layui-input-inline">
                <select name="testType">
                    <option value="1">笔试</option>
                    <option value="2">机试</option>
                    <option value="3">模拟面试</option>
                </select>
            </div>
            <div class="layui-form-mid layui-word-aux">必填项</div>
        </div>

        <%--     学期    --%>
        <div class="layui-form-item">
            <label class="layui-form-label">学期:</label>
            <div class="layui-input-inline">
                <select name="termId">
                    <c:forEach items="${tlist}" var="e">
                        <option value="${e.termId}">${e.termName}</option>
                    </c:forEach>
                </select>
            </div>
            <div class="layui-form-mid layui-word-aux">必填项</div>
        </div>

        <%--    考试时间--%>
        <div class="layui-form-item">
            <label class="layui-form-label">考试时间</label>
            <div class="layui-input-inline">
                <input type="text" name="scoreTime" id="scoreTime"  placeholder="考试时间"
                       autocomplete="off" class="layui-input" lay-verify="required">
            </div>
            <div class="layui-form-mid layui-word-aux">必填项</div>
        </div>

        <%--    备注--%>
        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-inline">
                <input type="text" name="remark" id="remark"  placeholder="备注"
                       autocomplete="off" class="layui-input" >
            </div>
<%--            <div class="layui-form-mid layui-word-aux">必填项</div>--%>
        </div>

        <%--    备注--%>
        <div class="layui-form-item">
            <div class="layui-input-inline">
                <input type="hidden" name="testName" id="testName" required lay-verify="" placeholder="备注"
                       autocomplete="off" class="layui-input" lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <button id="formbtn" type="button" lay-submit lay-filter="formbtn" class="layui-btn layui-btn-normal">
                提交
            </button>
            <%--            <button id="reset" type="reset" lay-submit lay-filter="formbtn" class="layui-btn layui-btn-normal">--%>
            <%--                重置--%>
            <%--            </button>--%>
        </div>
    </form>
</body>
</html>
